package com.adopapa.ethexplorer.service;

import java.util.Optional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.adopapa.ethexplorer.domain.WalletInfo;
import com.adopapa.ethexplorer.domain.WalletInfoRepository;

@Service
public class WalletInfoService extends BaseService {

	@Autowired
	private WalletInfoRepository walletInfoRepository;

	public WalletInfo getWalletInfoById(String id) {
		Optional<WalletInfo> optional = walletInfoRepository.findById(id);
		return optional.isPresent() ? optional.get() : null;
	}

//	public WalletInfo getWalletInfo(UserInfo userInfo) {
//		List<WalletInfo> results = walletInfoRepository.findByUserInfo(userInfo);
//		return Tools.empty(results) ? null : results.get(0);
//	}

	public WalletInfo saveWalletInfo(WalletInfo walletInfo) {
		return walletInfoRepository.saveAndFlush(walletInfo);
	}

	public void deleteWalletInfo(String id) {
		walletInfoRepository.deleteById(id);
	}

	public void deleteWalletInfo(WalletInfo walletInfo) {
		walletInfoRepository.delete(walletInfo);
	}

}
